/**
 *
 */
package com.angel.data.generator.base.impl;

import java.util.Collection;
import java.util.List;

import org.apache.log4j.Logger;

import com.angel.dao.generic.factory.DAOFactory;
import com.angel.data.generator.interfaces.DataGenerator;




/**
 * @author William
 *
 */
public class DataGeneratorAnnotationRunner extends DataGeneratorRunnerImpl{

    /**
     * Logger class.
     */
    private static Logger LOGGER = Logger.getLogger(DataGeneratorAnnotationRunner.class);

    public DataGeneratorAnnotationRunner(){
        super();
    }

    public DataGeneratorAnnotationRunner(DAOFactory daoFactory){
        super(daoFactory);
    }

    @Override
    public void addDataGenerator(DataGenerator dataGenerator){
        super.addDataGenerator(dataGenerator);
    }

    @Override
    public boolean removeDataGeneratorClass(Class<? extends DataGenerator> dataGeneratorClass){
        return super.removeDataGeneratorClass(dataGeneratorClass);
    }

    /** Generate all data for all data generators added.
     *
     * @return an instances domain object's collection.
     */
    public Collection<Object> generateData(){
    	LOGGER.info("Pre process was executed: [" + this.getPreProcessExecuted() + "].");
    	long init = System.currentTimeMillis();

        if(!this.getPreProcessExecuted()){
        	this.preProcess();
        }

        List<Object> dataGenerated = this.createAllNewData();

        long end = System.currentTimeMillis();
        LOGGER.info("Pre process was executed: [" + this.getPreProcessExecuted() + "].");
        LOGGER.info("Data generator process was executed correctly in [" + (end - init) + "] milliseconds.");
        return dataGenerated;
    }
}
